import { Button } from "antd";
import MyForm from "./components/myForm/index";

const MyBase: React.FC = () => {
  const onFinish = (values: Record<string, any>) => {
    console.log(values, "values");
  };

  const onFinishFailed = (errors: Record<string, any>) => {
    console.log(errors, "errors");
  };

  return (
    <>
      <div>
        <MyForm
          onFinishFailed={onFinishFailed}
          onFinish={onFinish}
          initialValues={{ name: "", age: 123 }}
        >
          <MyForm.Item
            name="name"
            rules={[
              {
                required: true,
                message: "请输入用户名!",
              },
              {
                max: 6,
                message: "长度不能大于 6",
              },
            ]}
          >
            <input />
          </MyForm.Item>
          <MyForm.Item name="age">
            <input />
          </MyForm.Item>
          <MyForm.Item>
            <Button type="primary" htmlType="submit">
              提交
            </Button>
          </MyForm.Item>
        </MyForm>
      </div>
    </>
  );
};

export default MyBase;
